<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<link rel="stylesheet" href="{{ url_for('static', filename='editor/css/editormd.css') }}">

{#<form  method="post">#}
<div id="test-editor">
{#        <textarea style="display:none;">### 关于 Editor.md#}
{##}
{#    **Editor.md** 是一款开源的、可嵌入的 Markdown 在线编辑器（组件），基于 CodeMirror、jQuery 和 Marked 构建。#}
{#        </textarea>#}
    <textarea class="editormd-markdown-textarea" name="test-editormd-markdown-doc"></textarea>
    <!-- 第二个隐藏文本域，用来构造生成的HTML代码，方便表单POST提交，这里的name可以任意取，后台接受时以这个name键为准 -->
    <textarea class="editormd-html-textarea" name="text"></textarea>

</div>
{#    <input type="submit" class="success">#}
{#</form>#}

<button class="btn btn-primary upBlog" style="margin-bottom: 2px;">发表博客</button>

<script src="https://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
<script src="{{ url_for('static', filename='editor/editormd.js') }}"></script>
{#<script src="editormd/editormd.min.js"></script>#}
<script type="text/javascript">
    $(function () {
        var editor = editormd("test-editor", {
            // width  : "100%",
            // height : "100%",
            height: 640,
            path: "{{ url_for('static', filename='editor/lib/') }}",
            imageUpload: true,
            imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
            imageUploadURL: "{{ url_for('bl.uploadfile') }}",
            saveHTMLToTextarea: true,
            codeFold: true,  // 折叠
              //下面这一行将使用dark主题
            // previewTheme : "dark"
        });
        $(".upBlog").on('click', function () {
            var getHtml = editor.getHTML();
            alert(getHtml);
            $.ajax({
                url: '{{ url_for('bl.index') }}',
                type: 'post',
                data: {"content_html": getHtml},
                success: function (data) {
                    console.log(data)
                }
            })
        })
    });
</script>
</body>
</html>